#!/bin/bash
#sync_devcloud.sh
#描述：同步到其他服务器
p=TkeStack@2020
all_ip=$*
 
for _ip in ${all_ip[@]}
do
echo "同步程序到"${_ip}
sshpass -p $p ssh root@${_ip} "mkdir -p /root/.ssh"
sshpass -p $p ssh root@${_ip} "touch /root/.ssh/authorized_keys"
sshpass -p $p ssh root@${_ip} "chmod 600 /root/.ssh/authorized_keys"
sshpass -p $p scp -drq /root/.ssh/id_rsa.pub root@${_ip}:/root/.ssh
sshpass -p $p ssh root@${_ip} "cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys"
sshpass -p $p ssh root@${_ip} "rm /root/.ssh/id_rsa.pub"
echo "同步完成"
done
